package com.presentacion.houseon;

import java.util.ArrayList;
import com.model.houseon.CasaBean;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.view.Window;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;

public class ListaCasaActivity extends Activity implements OnItemClickListener  {

	ListView lstCasas;
	CasaBean c1,c2;
	ArrayList<CasaBean> lista;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		//requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
		setContentView(R.layout.activity_lista_casa);
		
		//getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.activity_barra_titulo);
		
		
		lstCasas =(ListView)findViewById(R.id.lstCasa);
		
		c1= new CasaBean(1, "Casa Playa", "600", "10.0.0.2", "drawable/casa", "ww.ejemplo.com", true);
		c2= new CasaBean(2, "Casa Punta Sal", "600", "10.0.0.3", "drawable/casa", "ww.ejemplo.com", true);
		
		lista= new ArrayList<CasaBean>();
		lista.add(c1);
		lista.add(c2);
		
		ItemCasaAdapter item=new ItemCasaAdapter(ListaCasaActivity.this, lista);
		lstCasas.setAdapter(item);
		
		
		lstCasas.setOnItemClickListener(new OnItemClickListener() {

			@Override
			public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,
					long arg3) {
				
				
				// TODO Auto-generated method stub
				Toast.makeText(getApplicationContext(), ((TextView)arg1).getText().toString(), Toast.LENGTH_LONG).show();
				Intent i= new Intent(ListaCasaActivity.this, CategoriasCasaActivity.class);
				//i.putExtra("idCasa", value)  --> aca se guarda el id para la buscar en la sgt pantalla
				startActivity(i);
			}
			
		});
		
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.lista_casa, menu);
		return true;
	}

	@Override
	public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
		// TODO Auto-generated method stub
		
		Toast.makeText(getApplicationContext(), ((TextView)arg1).getText().toString(), Toast.LENGTH_LONG).show();
		
	}

}
